package com.bw.zhuangao5___day002.Fragment.Music;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * create by ertu
 * create on 2021/9/24
 * description
 */
public class MuiscOkhttps {
    public static MuiscOkhttps muiscOkhttps;
    public Retrofit retrofitmuisc;
    public static MuiscOkhttps getMuiscOkhttps()
    {
        if (muiscOkhttps==null)
        {
            synchronized (MuiscOkhttps.class)
            {
                muiscOkhttps  = new MuiscOkhttps();
            }
        }
        return muiscOkhttps;
    }

    public Retrofit retrofition(String nimi)
    {
        if (retrofitmuisc==null)
        {
            synchronized (Retrofit.class)
            {
                if (retrofitmuisc==null)
                {
                    retrofitmuisc = new Retrofit.Builder().baseUrl(nimi)
                            .client(new OkHttpClient.Builder()
                                    .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                                    .build())
                            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                            .addConverterFactory(GsonConverterFactory.create())
                            .build();
                }
            }
        }
        return retrofitmuisc;
    }
}
